package com.song.springclouddemoshardingjdbc.controller;

import com.song.springclouddemoshardingjdbc.entity.Order;
import com.song.springclouddemoshardingjdbc.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderMapper orderMapper;


    // http://localhost:8888/order/save
    @GetMapping("/save")
    public String insert() {
        Order order = new Order();
        //order.setId(10001L);
        order.setUserid(227221L);
        order.setCreateTime(new Date());
        order.setOrdernumber("DN123456789");
        order.setYearmonth("202203");
        orderMapper.addOrder(order);
        return "success";
    }
    /*
          坑： 生成雪花算法id时候，其他属性值也要填写默认值，否则，id就会生成到别的属性列的位置  这里找了好久这个问题
     */


}
